package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.acticle.domain.Destination;
import cn.wolfcode.luowowo.acticle.domain.Destination;
import cn.wolfcode.luowowo.acticle.query.DestinationQueryObject;
import cn.wolfcode.luowowo.acticle.query.DestinationQueryObject;
import cn.wolfcode.luowowo.acticle.service.IDestinationService;
import cn.wolfcode.luowowo.acticle.service.IDestinationService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 区域控制器
 */
@Controller
@RequestMapping("/destination")
public class DestinationController {
    @Reference
    private IDestinationService destinationService;
    //列表功能
    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") DestinationQueryObject qo){
        PageInfo pageInfo = destinationService .query(qo);
        model.addAttribute("pageInfo", pageInfo);
        model.addAttribute("toasts", destinationService.getToasts(qo.getParentId()));
        return "destination/list";
    }
    //修改状态
    @RequestMapping("/changeHotValue")
    @ResponseBody
    public Object changeHotValue(Integer hot, Long id){
        destinationService.changeHotValue(hot, id);
        return new AjaxResult();
    }
    //编辑简介
    @RequestMapping("/setInfo")
    @ResponseBody
    public Object setInfo(String info, Long id){
        destinationService.setInfo(info, id);
        return new AjaxResult();
    }
    //删除地区
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id){
        destinationService.delete(id);
        return new AjaxResult();
    }

}
